// Have include guard.
#ifndef CONTROLLERSELECTORCONTROLLER_H
#define CONTROLLERSELECTORCONTROLLER_H

// Include files.
#include <string>
#include "RobotController.hpp"
#include "SelectorController.hpp"
#include "ValueOutput.hpp"

class SystematicRobot;

/**
 *  The ControllerSelectorController selects a RobotController to be active from a list based on some input.
 * 
 *  When ControllerSelectorController selects a new RobotController, it deactivated the one that was previously 
 *  selected (if any), and activates the newly select one.
 *  
 *  This is useful for switching driving modes based on the driver's preference.
 *  
 *  Testing shows this class mostly works.
 */
class ControllerSelectorController :
	public SelectorController<RobotController*>
{
	private:
		typedef RobotController *Item;
		
		SystematicRobot *m_robot;
	public:
		ControllerSelectorController(HumanDigitalInput &upInput, HumanDigitalInput &downInput, ValueOutput<std::string> &valueOutput);
		ControllerSelectorController(DriverStationEnhancedIO &driverStationIo, UINT32 buttonUp, UINT32 buttonDown, ValueOutput<std::string> &valueOutput);
		
		virtual ~ControllerSelectorController();
	protected:
		virtual void HandleAddedToRobot(SystematicRobot &robot);
		virtual void HandleItemAdded(RobotController *controller);
		virtual void HandleItemSelectedImpl(RobotController *controller);
		virtual void HandleItemUnselectedImpl(RobotController *controller);
};

#endif // #ifndef CONTROLLERSELECTORCONTROLLER_H
